//
//  CoderLoginViewController.m
//  帮惠Mall
//
//  Created by reew on 2017/9/14.
//  Copyright © 2017年 reew. All rights reserved.
//

#import "CoderLoginViewController.h"
#import "PhoneLoginViewController.h"
#import "CommonUtils.h"
#import <SVProgressHUD.h>
@interface CoderLoginViewController ()

@property (weak, nonatomic) IBOutlet UITextField *phoneNum;
@end

@implementation CoderLoginViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    //设置label左视图
    UILabel *leftLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 80, 45)];
    leftLabel.text = @"+86";
    leftLabel.font = [UIFont systemFontOfSize:18];
    _phoneNum.leftViewMode = UITextFieldViewModeAlways;
    _phoneNum.leftView = leftLabel;
    self.navigationController.navigationBarHidden = YES;
}
- (IBAction)close:(UIButton *)sender {
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    
    // Dispose of any resources that can be recreated.
}
-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    [self.phoneNum resignFirstResponder];
   
}
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
    PhoneLoginViewController *vc = [segue destinationViewController];
    vc.phone = _phoneNum.text;
}
- (BOOL)shouldPerformSegueWithIdentifier:(NSString *)identifier sender:(id)sender{
    if ([CommonUtils isPhoneNum: _phoneNum.text]) {
        return YES;
    }else{
        [SVProgressHUD showErrorWithStatus:@"请输入正确的手机号"];
        return NO;
    }
}
@end
